#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_btn_openDIr_clicked()
{
    QString dirName = QFileDialog::getExistingDirectory(this,"测试打开目录");
    if(dirName.isEmpty())
        return;

    ui->lineEdit->setText(dirName);

    QDir opendir(dirName);
    opendir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    QFileInfoList infoList = opendir.entryInfoList();

    ui->textEdit->clear();

    for(int i = 0; i<infoList.size(); i++)
    {
        QFileInfo info = infoList.at(i);
        ui->textEdit->append(
            "文件名:" + info.fileName() + "\t" +
            "文件大小:" + QString("%1").arg(info.size()) + "\t" +
            "文件所有者用户名:" + info.owner());
    }
}

